let html = document.documentElement
function setFont() {
  var hw=html.offsetWidth;
  var hs=(hw/375)*100; //计算当前页面字体大小
  hs = Math.round(hs);
  html.style.fontSize=hs+"px";
}
setFont();
//防抖函数
let timer=null;
window.addEventListener("resize",debounce(200));
var debounce = function(delay) {
    clearTimeout(timer);
    timer = setTimeout(() => {
      setFont();      
    }, delay);
}


$(function() {
    function setRem(){
        var clientWidth=$(window).width();
        var nowRem=(clientWidth/375*10);
        $("html").css("font-size",parseInt(nowRem, 10)+"px");
    };
    setRem();

    $(function(){
        var timer;
        $(window).bind("resize",function(){
            clearTimeout(timer)
            timer=setTimeout(function(){
                setRem();
            }, 100)
        })
    });
});
